package com.wy.controller;

import com.wy.pojo.Course;
import com.wy.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wuyue
 * @date 2020/1/6 23:19
 */

@RestController
@RequestMapping("/course")
@RefreshScope //刷新配置
public class CourseController {
       @Autowired
       private CourseService courseService;
       @Value("${test.name}")
       private String names;

        @GetMapping("/{name}")
    public List<Course> findByName(@PathVariable String name){
            System.out.println(names);
            /* 测试Hystrix的熔断效果
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }*/
            return courseService.findByName(name);
    }
}
